// ==UserScript==
// @name         添加购买链接
// @namespace 	 test
// @version      1.0.0
// @description  添加购买链接
// @author       Zoro.Zhu
// @include      https://www.dianxiaomi.com/product/edit.htm*purchaseUrl*
// @connect      *
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// @grant        window.close
// ==/UserScript==

(function() {
    var url = window.location.href;
    var arr=url.split("purchaseUrl=");
    var purchaseUrl = decodeURI(arr[1]);
    purchaseUrl = JSON.parse(purchaseUrl);
    var inputId = 'sourceUrl1';
    var id = '';
    for(var i in purchaseUrl) {
        id = 5 + parseInt(i);
        id = inputId + id;
        $('.source-url-add').click();
        $('#' + id).val(purchaseUrl[i]);
    }
    $('.source-url-save').click();
    setTimeout(function(){
        window.close();
    },1000);
})();
